﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SERP.StringMappings;
using SERP.DAO;
using SERP.Controllers;
namespace SERP.Modules.Organizations{
	public partial class OrganizationsViewInfo : SERP.Modules.ModuleBase
	{
		private OrganizationsController controller = new OrganizationsController();
		public OrganizationsController Controller{
			get{
				return controller;
			} 
		}
		protected void Page_Load(object sender, EventArgs e){
    		LoadLanguage();	
			if(!this.IsPostBack){		
				BindInfo();	
			}
		}
		//Load All lable text
		private void LoadLanguage(){
			labelOrgCode.Text=OrganizationsStringMapping.OrgCode+":";
			labelOrgName.Text=OrganizationsStringMapping.OrgName+":";
			labelNote.Text=OrganizationsStringMapping.Note+":";
			labelOrgType.Text=OrganizationsStringMapping.OrgType+":";
			labelParentId.Text=OrganizationsStringMapping.ParentId+":";
		}
		public OrganizationsEntity GetObject(){
			controller.LoadObject(Int32.Parse(Request["OrganizationId"]));
			return controller.OrganizationsObject;
		}
		private void BindInfo(){
			OrganizationsEntity o=GetObject();		
			CopyToSreen(o);
			BindParentId(o);
		}
		private void BindParentId(OrganizationsEntity o){
			OrganizationsController ctrlOrganizations = new OrganizationsController();
			ctrlOrganizations.LoadObject(o.ParentId);
			OrganizationsEntity oOrganizations=ctrlOrganizations.OrganizationsObject;
			if(oOrganizations!=null){
				txtParentId.Text = oOrganizations.OrgName.ToString();
			}
			else{
				txtParentId.Text = "";
			}
		}
		private void CopyToSreen(OrganizationsEntity o){
			txtOrgCode.Text=o.OrgCode;
			txtOrgName.Text=o.OrgName;
			txtNote.Text=o.Note;
			txtOrgType.Text=Convert.ToString(o.OrgType);
		}   
}
}
